<template>
    <div id="temp">
        <h3>{{goodsIntro.title}}</h3>
        <hr>
        <div v-html="goodsIntro.content"></div>
    </div>
</template>
<script>
export default {
    data() {
        return {
            id: 0,
            goodsIntro: []
        }
    },
    created() {
        this.id = this.$route.params.id;
        this.getGoodsintro()
    },
    updated() {
        var tempWidth = document.getElementById("temp").offsetWidth - 20,
            imgs = document.querySelectorAll("p img");
        imgs.forEach(function (v) {
            v.style.width = tempWidth + "px";
        })
    },
    methods: {
        getGoodsintro() {
            this.$http.get("http://182.254.146.100:8899/api/goods/getdesc/" + this.id)
                .then(function (res) {
                    if (res.body.status != 0) {
                        Toast({
                            message: res.body.message,
                            duration: 3000
                        });
                        return;
                    }
                    this.goodsIntro = res.body.message[0];
                })
        }
    },

}
</script>
<style scoped>
#temp {
    width: 100%;
    box-sizing: border-box;
    padding: 10px;
    overflow: hidden;
}

h3 {
    color: #0094ff;
    line-height: 30px;
}

p img {
    width: 300px !important;
}
</style>


